package iss.java;

import iss.java.list.MyList;

/**
 * Created by wenke on 2016/9/16.
 */
public class Main_A {
    public static final Object obj = new Object();

    public static void main(String[] args)throws InterruptedException {
        // TODO: Implement a multithreaded test case against requirement A.
        MyList mylist = new MyList();

        Thread ta = new Thread(){
            @Override
            public void run(){
                  synchronized (obj){
                      for(int i = 0;i < 10 ; ++i){
                          mylist.getHead().setData(mylist.getHead().getData()+10);
                      }
                  }
            }
        };

        Thread tb = new Thread(){
            @Override
            public  void run(){
                synchronized(obj){
                    for(int i = 0; i<5;++i){
                        mylist.getHead().setData(mylist.getHead().getData()-10);
                    }
                }
            }
        };

        ta.start();
        tb.start();
        Thread.sleep(100);
        System.out.println(mylist.getHead().getData());
    }
}
